home *** CD-ROM | disk | FTP | other *** search
/ Winzipper / Winzipper_ISO.iso / cad / drafix quickcad / PRO400 / MACROS / SIZEDDE.D < prev    next >
Encoding:
Text File  |  1996-01-16  |  2.2 KB  |  76 lines

  1. // sizedde.d
  2. // Dumps symbol list from active drawing into Excel spreadsheet
  3. // Also calculates the horizontal and vertical extents  in millimeters and dumps those values 
  4. // This creates a check list in Excel with names and horizontal/vertical sizes
  5.  
  6. // Copyright (c) 1991-1996 Softdesk, Inc.
  7. // Author: SAC    1/96
  8.  
  9. HANDLE    hChan;        //handle to dde chanel
  10. HANDLE    hXYChan;
  11. HANDLE    hSymList;
  12. STRING    sSymbol;
  13. STRING    s, sSheet;
  14. XY    xyMin, xyMax;    
  15.  
  16. SetData("UnitLinearType", 5);
  17. // get name of spreadsheet to use
  18. if (!GetUser("string", "Enter Excel Sheetname to output to", &sSheet))
  19.     Exit(%cancel, "Macro canceled!");
  20.  
  21. // default to "Sheet1"
  22. if (StringLength(sSheet) == 0)
  23.     sSheet = "Sheet1";
  24. Print ("SheetName is ", sSheet, "\n");
  25.  
  26. // start conversation with Excel
  27. hChan = Open("dde", "excel", sSheet);
  28. Print ("Conversation ", hChan, "\n");
  29.  
  30. // if conversation is established (if Excel was already running)
  31. // poke values into the spreadsheet
  32. if (hChan > 0)
  33. {
  34.     // title
  35.     Poke(hChan, "r1c1", "Drafix WinCAD DDE in Action");
  36. //    GetUser("string", "What type of symbol/Library is it?", slibtype);
  37. //    Poke(hChan, "r
  38.     // export symbol list
  39.     Poke(hChan, "r5c1", "Symbol List");
  40.     Poke(hChan, "r5c2", "X SIZE");
  41.     Poke(hChan, "r5c3", "Y SIZE");
  42.     Poke(hChan, "r5c4", "DONE");
  43.     Poke(hChan, "r5c5", "CHECKED");
  44.     
  45.     hSymList = Open("symlist", "*");
  46.     if (hSymList)
  47.     {
  48.         i = 7;
  49.         // loop through symbols in drawing
  50.         while (GetNextSymbol(hSymList, &sSymbol))
  51.         {
  52.             nCount = Symbol("getcount", sSymbol);
  53.             GetSymbolExtent(sSymbol, &xyMin, &xyMax);
  54.             // format r#c# reference using MakeString
  55.             Poke(hChan, MakeString("cell", i, 1), sSymbol);
  56.             Poke(hChan, MakeString("cell", i, 2), Format("length", abs(xyMax.x-xyMin.x)));
  57.             Poke(hChan, MakeString("cell", i, 3), Format("length", abs(xyMax.y-xyMin.y)));
  58. //            Poke(hChan, MakeString("cell", i, 4), Format("scalar", nCount));
  59.             i = i+1;
  60.         }    
  61.     }
  62.     else
  63.         Poke(hChan, "r11c1", "No symbols.");
  64.  
  65.     // an excel macro could be executed to format the data
  66.     // using the Execute("dde", ...) command at this time.
  67.  
  68.     // close conversation
  69.     Close("dde", hChan);
  70. }
  71. else
  72.     Exit(%abort, "Couldn't start conversation with Excel\n");
  73.  
  74. Exit(%ok, "Done with DDE conversation.");
  75. // [EndOfMacro]